import { getDept } from '@/common/api/auth'
const state = {
  deptData: [],
}
const getters = {
  deptData: state => state.deptData,
}
const actions = {
  async getDeptData({ commit }, force = true) {
    if (!force && state.deptData) {
      return Promise.resolve(state.myTaskCount)
    }
    const res = await getDept({ deptLevel: '', clientId: '', deptName: '' })
    const data = (res && res.data) || []
    commit('deptData', data)
    return data
  },
}
const mutations = {
  deptData: (state, payload) => (state.deptData = payload),
}
export default {
  state,
  getters,
  actions,
  mutations,
}
